//
//  GGDeviceManagementViewController.m
//  DDLock
//
//  Created by ios on 2017/12/29.
//  Copyright © 2017年 saiyi. All rights reserved.
//

#import "GGDeviceManagementViewController.h"
#import "GGDeviceAddFellowViewController.h"
#import "GGDeviceCell.h"

@interface GGDeviceManagementViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation GGDeviceManagementViewController

static NSString * GGDeviceCellID = @"GGDeviceCell";

- (void)setDidLoad {
    [super setDidLoad];
    
    self.title = @"权限管理";
    
    [self _setInitialize];
    
}

- (void)_setInitialize {
    
    
    [self setAddTableView:UITableViewStylePlain frame:self.view.frame target:self];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.tableView registerNib:[UINib nibWithNibName:GGDeviceCellID bundle:nil] forCellReuseIdentifier:GGDeviceCellID];
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"add"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(clickAdd)];
    
    
}


#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    GGDeviceCell *cell = [tableView dequeueReusableCellWithIdentifier:GGDeviceCellID];
    cell.actionBtn.hidden = YES;
    
    
    return cell;
    
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}


#pragma mark - UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [GGDeviceCell cellHeight];
}

- (nullable NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewRowAction *action01 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
        
    }];
    
    UITableViewRowAction *action02 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"更名" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
        
    }];
    
    return @[action01, action02];
}






#pragma mark - target
// 添加好友
- (void)clickAdd {
    
    GGDeviceAddFellowViewController *addFellowVC = [[GGDeviceAddFellowViewController alloc] init];
    [self.navigationController pushViewController:addFellowVC animated:YES];
    
}

@end
